package cn.dkk.behavior_design.iterator;

import java.util.List;

/**
 * @author dkk
 * @date 2022/7/31
 * @desc
 */
public class StudentIteratorImpl implements StudentIterator {

    private List<Student> studentList; // list实现迭代器

    private int index = 0; // 下标

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    public int getIndex() {
        return index;
    }


    @Override
    public boolean hasNext() {
        return index<studentList.size();
    }

    @Override
    public Student next() {
        Student student = studentList.get(index);
        index++;
        return student;
    }
}
